/*
 * Copyright (c) 2010 Network Security Lab (NSL), Department of Electrical
 *                    Engineering, University of Washington
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation;
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * Author: He Wu mdzz@uw.edu
 */

/**
 * @file socket.h
 * @brief Socket functions for base node to communicate with control GUI.
 */

#ifndef SOCKET_H
#define SOCKET_H

#include "network.h"

/******************************************************************************/

#define BUFFER_LEN 512  //!< length of buffer for storing commands from GUI
#define CMD_PORT 8081   //!< port number for receiving commands from GUI
#define DATA_PORT 8082  //!< port number for sending data to GUI
#define SOCKET_UPDATE_INTEVAL 100000  //!< Socket update interval, in us
#define GUI_IP "192.168.99.100"       //!< IP address for GUI

/******************************************************************************/

/**
 * @brief Receive commands from GUI. Run as thread.
 * @param cmd_list Pointer to list of commands to store on base node.
 */
void *cmdSocket(__u8 *cmd_list);

/**
 * @brief Send localization data back to GUI via socket.
 * @param in_pkt Received localization packet.
 * @return 0 if all is good.
 */
int dataSocket(packet in_pkt);

/**
 * @brief Sends packets that failed to send back to GUI.
 * @param in_pkt Packets that failed to send.
 * @return 0 if all is good.
 */
int errorSocket(packet in_pkt);

/**
 * @brief Send base-to-node routing table back to GUI.
 * @param routingTable Pointer to base-to-node routing table.
 * @param routingTable_size Size of base-to-node routing table.
 * @return 0 if all is good.
 */
int routingSocket(__u16 *routingTable, __u8 routingTable_size);

#endif
